每个程序的生命始于一个 源程序 (或源文件)。从最基本层面看,你的代码不过是一串按8位分组的比特序列,这些分组被称为 字节。对我们而言,它是逻辑;对计算机而言,它是一份数字形式的数值编码手稿。
1. ASCII 标准
为确保你输入的字符 int 与计算机读取的字符 ASCII 标准一致,我们使用 # 被存储为字节值 $35$,而 i i
| 字符 | # | i | n | c | l | u | d | e |
|---|---|---|---|---|---|---|---|---|
| ASCII | 35 | 105 | 110 | 99 | 108 | 117 | 100 | 101 |
2. 文本文件与二进制文件的区别
文本文件和二进制文件之间的区别完全取决于 文本文件 和 二进制文件 上下文。仅包含 ASCII 字符的文件是文本文件;其余所有文件均为二进制文件。在这一初始的“源码”阶段,你的程序仅以一连串数值编码的线性字符串形式存在。
main.py
TERMINALbash — 80x24
> Ready. Click "Run" to execute.
>
QUESTION 1
What is the fundamental 8-bit unit used to store characters in a source file?
A Nibble
A Byte
A Word
A Bit
✅ Correct!
Exactly! Bytes are the 8-bit blocks that represent individual characters in source code.❌ Incorrect
While a bit is the smallest unit, source files organize them into 8-bit 'bytes' to represent characters.QUESTION 2
Which standard maps the character 'i' to the decimal value 105?
$UTF-32$
EBCDIC
ASCII
IEEE 754
✅ Correct!
The American Standard Code for Information Interchange (ASCII) is the foundational mapping for text in computer systems.❌ Incorrect
IEEE 754 is for floating-point numbers. ASCII is for character encoding.QUESTION 3
What distinguishes a 'text file' from a 'binary file'?
The file size in kilobytes.
The use of encryption.
Whether it contains entirely ASCII characters.
The presence of a main() function.
✅ Correct!
Correct! If a file's bytes represent ASCII characters, it is considered a text file.❌ Incorrect
The distinction is context-based: if every byte is an ASCII character, it's text. Otherwise, it's binary.QUESTION 4
In the 'hello.c' example, how does the computer store the '#' character?
As a graphical pixel map.
As the bit pattern 00100011 (decimal 35).
As the string 'HASH'.
It doesn't store it until compilation.
✅ Correct!
Yes. The editor translates the '#' keypress into the specific binary pattern assigned by ASCII.❌ Incorrect
The computer stores characters as numeric byte patterns immediately upon saving the file.QUESTION 5
True or False: The file system knows the logic of C code when you save a .c file.
True
False
✅ Correct!
Correct. To the file system, hello.c is just a linear sequence of bytes. Logic is only applied during translation.❌ Incorrect
The file system only sees data. The C logic is interpreted later by the compilation system.Case Study: The Digital Manuscript
Interpreting Raw Byte Streams
You open a file and see the following hex sequence: 0x69 0x6E 0x74. Using the ASCII table where 'i'=105 (0x69), 'n'=110 (0x6E), and 't'=116 (0x74), evaluate how this is treated by the system.
Q
1. Is this file initially considered a text file or a binary file?
Solution:
It is a text file. All three bytes represent standard ASCII characters that form the word 'int'.
It is a text file. All three bytes represent standard ASCII characters that form the word 'int'.
Q
2. If the next byte was 0xFF (not in ASCII), how would the classification change?
Solution:
The file would then be classified as a binary file, because it contains a byte value that does not correspond to a standard ASCII character.
The file would then be classified as a binary file, because it contains a byte value that does not correspond to a standard ASCII character.